/***** init section, begin *****/
$(document).ready(
    function() {
       initHeartbeat();
    }
);


function initHeartbeat()
{
    $(document).everyTime("300s", function(i) {
        heartBeat(i);
    }, 0);
}

function heartBeat(i)
{
//    wacDebugLog(i);

    var params = "data_format=json";
    var submitUrl;

    submitUrl = BASE_URL + "default/heartBeat";

    $.ajax({
        url: submitUrl,
//        url: BASE_URL + "test/ajaxTest" ,
        global: true,
        type: "GET",
        data: params,
        dataType: "json",
        success: function(jsonData){
            heartBeatCallBack(jsonData);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            wacDebugLog("heartBeat Error: " + $(this).dump()); // the options for this ajax request
            wacRedirect("/logout");
        }
    });
}

function heartBeatCallBack(jsonData)
{
   if(jsonData.info.status == wacOperationStatus.Error)
   {
       wacShowTips(jsonData.info.error_info);
       wacRedirect("/logout");
   }
//   else
//   {
//       wacShowTips(jsonData.info.tips);
//   }
//
//   wacDebugLog($.dump(jsonData));
}